Skip to content

refactor: migrate to Session API with improved caching and cross-platform support#89

Merged
branchseer merged 79 commits intomainfrom
01-08-feat_adopt_vite-task_s_session_api
Jan 10, 2026
Merged

refactor: migrate to Session API with improved caching and cross-platform support#89
branchseer merged 79 commits intomainfrom
01-08-feat_adopt_vite-task_s_session_api

Conversation

@branchseer
Copy link
Copy Markdown
Member

@branchseer branchseer commented Jan 9, 2026

Summary

Major refactoring of the task execution system with a new Session-based architecture, improved caching with detailed miss reasons, and comprehensive cross-platform support.

Architecture Changes

  • Migrate to new Session API, removing legacy code from vite_task
  • Add new vite_task_bin crate for CLI and test infrastructure
  • Implement event-based Reporter trait with LabeledReporter for formatted output
  • Move cache status from Finish to Start event for immediate feedback

Cache System Improvements

  • Display specific cache miss reasons (env changes, input changes, cwd changes)
  • Add option to disable cache per-task
  • Show simplified cache status for single built-in commands
  • Improve cache statistics display in execution summary

Execution Infrastructure

  • Implement execute_spawn() with fspy tracking for file system access monitoring
  • Real-time output emission during spawn execution using tokio::select!
  • Add PostRunFingerprint for content-based cache invalidation
  • Support for synthetic tasks with additional_envs field

Cross-Platform Fixes

  • Windows path handling in snapshot redaction
  • Use @yarnpkg/shell for cross-platform e2e tests
  • Preserve Windows system env vars for cmd.exe compatibility
  • Track FindFirstFile/FindNextFile on Windows for cache invalidation

Testing

  • Add comprehensive e2e test fixtures (cache-disabled, cache-keys, cache-miss-reasons, etc.)
  • New snapshot test infrastructure with path and duration redaction
  • Add test_bins utilities for testing (json-edit, print-env, print-file, replace-file-content)

Other Changes

  • Fix spelling: "Syntatic" → "Syntactic"
  • Add workspace node_modules/.bin to session PATH
  • Various CI workflow fixes

🤖 Generated with Claude Code

branchseer and others added 30 commits December 22, 2025 02:38
…rter

Implements the full execution loop in the new session architecture, enabling actual task execution with intelligent caching and formatted output.

Core changes:
- Implement execute_spawn() with fspy tracking for file system access monitoring
- Create PostRunFingerprint for content-based cache invalidation
- Wire up LabeledReporter for formatted execution output with cache status
- Migrate cache to use SpawnFingerprint from vite_task_plan
- Add workspace_path() getter and make session module public

Test infrastructure:
- Add vite-task-smoke e2e test with replace-file-content utility
- Add duration redaction to snapshot tests
- Verify cache hit/miss detection with file modifications

The execution now properly tracks file reads, validates fingerprints, and displays execution progress with cache status indicators.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace ExecuteError enum with event-based error reporting through the Reporter trait. Errors are now emitted as events and stop execution immediately via internal ExecutionAborted error.

Key changes:
- Add Reporter trait with handle_event() and post_execution() methods
- Remove ExecuteError and PathError enums
- Make ExecutionItemDisplay optional in Start event (None for top-level, Some for nested)
- Convert all error returns to error events
- Add internal ExecutionAborted type for error propagation via ? operator
- Update Session::execute to accept Box<dyn Reporter> instead of closure
- Implement Reporter trait for LabeledReporter with error tracking
- Fix top-level leaf execution for built-in commands
- Add cycle dependency error test fixture

All tests pass with updated snapshots.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
branchseer and others added 16 commits January 9, 2026 23:54
- Add oxc-project/setup-node before pnpm install for ubuntu/windows
- Move actions/setup-node before pnpm install for x86_64-apple-darwin
  to ensure correct native binaries are installed
- Redact thread count in oxlint output for consistent snapshots
  across machines with different CPU counts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Strip .CMD, .BAT, .EXE, .COM extensions from program_name in JSON
snapshots for cross-platform consistency. On Windows, resolved program
paths include these extensions but Unix doesn't use them.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The program_path field in spawn_command also includes the Windows
executable extension (.CMD) which needs to be stripped for cross-
platform snapshot consistency.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Handle both backslash and forward slash variants of paths for
  workspace_root and manifest_dir redaction
- Normalize PATH separator from ; (Windows) to : (Unix) for
  cross-platform consistency

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
cmd.exe doesn't handle quoted arguments with embedded equals signs and
brackets correctly. PowerShell has much better argument parsing that
matches Unix shell behavior.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
cmd.exe needs system environment variables to function correctly.
Instead of clearing all env vars on Windows, only clear them on Unix.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Replace platform-specific shell (cmd.exe/sh) with @yarnpkg/shell
  for consistent cross-platform behavior in e2e tests
- Add Node.js experimental warning filtering in redact.rs to handle
  Type Stripping warnings from newer Node.js versions
- Add @yarnpkg/shell 4.1.3 dependency to test_bins
- Use `which` crate to locate shell executable in test_bins

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When oxlint scans a directory, it uses FindFirstFile/FindNextFile Win32
APIs to enumerate files. Without intercepting these calls, fspy wouldn't
see READ_DIR accesses, causing the cache to miss file additions.

This fix:
- Adds detours for FindFirstFileW and FindFirstFileExW
- Uses GetCurrentDirectoryW for relative patterns like "*"
- Fixes fingerprint.rs to handle paths with trailing backslash

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
NtQueryDirectoryFile is already being intercepted at NT level, which
correctly captures READ_DIR accesses when programs enumerate directories.
The FindFirstFile Win32 API interception was unnecessary as it's just a
wrapper around the NT API.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
On Windows CI, terminal color detection may behave differently, causing
ANSI escape codes to appear in snapshot output even with NO_COLOR=1 set.
Explicitly setting FORCE_COLOR=0 ensures colors are fully disabled.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The auto-add FORCE_COLOR logic was causing issues on Windows CI where
stdout might be detected as supporting colors even when it's not a TTY.
This caused oxlint to output ANSI color codes in its output.

Changes:
- Add IsTerminal check before auto-adding FORCE_COLOR
- Also check FORCE_COLOR=0 in reporter color detection

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@branchseer branchseer changed the title feat: tui feat: task plan execution Jan 10, 2026
@branchseer branchseer changed the title feat: task plan execution refactor: migrate to Session API with improved caching and cross-platform support Jan 10, 2026
branchseer and others added 3 commits January 10, 2026 17:35
- Return 0 if all tasks succeed
- Return the task's exit code if exactly one task failed
- Return 1 if more than one task failed

Update vite_task_bin to propagate the exit code to the process.
Add e2e tests to verify exit code behavior.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
… ExitCode>

Use Result type for clearer success/failure semantics:
- Ok(()) for success (exit code 0)
- Err(ExitCode) for failure with specific exit code

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements a major refactoring of the task execution system with a new Session-based architecture, improved caching with detailed miss reasons, and comprehensive cross-platform support.

Changes:

  • Migrates to new Session API with event-based Reporter trait for execution feedback
  • Implements detailed cache miss tracking (env changes, input changes, cwd changes) and cache metadata system
  • Adds cross-platform support with Windows path handling, @yarnpkg/shell for tests, and proper environment variable preservation

Reviewed changes

Copilot reviewed 151 out of 211 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pnpm-workspace.yaml Adds test_bins workspace and new dependencies (oxlint, @yarnpkg/shell)
pnpm-lock.yaml Updates lockfile with new test dependencies
package.json Adds new dev dependencies and test scripts
crates/vite_task_plan/src/plan_request.rs Adds envs field to SyntheticPlanRequest for environment customization
crates/vite_task_plan/src/plan.rs Implements cd command handling, which() function, and cache key generation
crates/vite_task_plan/src/path_env.rs Adds case-insensitive PATH lookup for Windows
crates/vite_task_plan/src/lib.rs Refactors to use SpawnCommand and CacheMetadata structures
crates/vite_task_plan/src/cache_metadata.rs New file defining cache metadata structures
crates/vite_task_graph/src/lib.rs Refactors TaskId to be private, adds TaskDisplay to TaskNode
crates/vite_task_graph/src/display.rs Updates TaskDisplay formatting
crates/vite_task_graph/src/config/*.rs Restructures cache configuration with EnabledCacheConfig
crates/vite_task_bin/tests/* Adds comprehensive snapshot testing infrastructure
crates/vite_task_bin/test_bins/* Adds test utility programs (print-file, json-edit, etc.)
crates/vite_task_bin/src/* New binary implementation with Session API usage
crates/vite_task/src/session/* New session module with Reporter, cache, and execution logic
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@branchseer branchseer merged commit b0067a9 into main Jan 10, 2026
13 checks passed
@branchseer branchseer deleted the 01-08-feat_adopt_vite-task_s_session_api branch January 10, 2026 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants